/**
 * 在组合继承的基础上，对原型成员的继承过程进行优化
 */
function Parent(instanceAttr) {
  this.instanceAttr = instanceAttr
  this.instanceFn = function () {
    console.log('instanceFn')
  }
}
Parent.prototype.prototypeAttr = 'prototypeAttr'
Parent.prototype.prototypeFn = function () {
  console.log('prototypeFn')
}

function Child() {
  Parent.apply(this, arguments)
}
// 通过 Object.create() 对原型成员的继承过程进行优化
Child.prototype = Object.create(Parent.prototype)
Child.prototype.constructor = Child

var child = new Child('instanceAttr')
console.log(child.instanceAttr)
child.instanceFn()
console.log(child.prototypeAttr)
child.prototypeFn()
